﻿package com.xuanque.mahjongDice.display
{
	import flash.display.*;
	import flash.events.*;
	import utils.transitions.*;
	
	import com.xuanque.mahjongDice.events.ResizeEvent;
	
	public class UnfoldBar extends Sprite
	{
		private var isTween:Boolean;
		private var _width:Number;
		
		public function UnfoldBar(){
			this._width = this.parent.width;
			
			addListener();
			
		}
		
		private function addListener(){
			this.Undold_btn.addEventListener(MouseEvent.CLICK,undoldHandler);
		}
		
		private function undoldHandler(event:MouseEvent){
			var _btn = event.target as SimpleButton;
			if(this.isTween == false){
				_btn.scaleX = -1;
				Tweener.addTween(this.parent,{x: 1000,time:.5});
			}else{
				_btn.scaleX = 1;
				Tweener.addTween(this.parent,{x:788,time:.5});
			}
			
			this.isTween = !this.isTween;
			
			var resizeEvent:ResizeEvent = new ResizeEvent();
			resizeEvent.isUndold = this.isTween;
			dispatchEvent(resizeEvent); //
			
		}
		
		
	}
}